using System;
using System.Web.UI.WebControls;
using Microsoft.SharePoint.WebControls;
using Ventigrate.Shared.ExternalMembership.Internal;

namespace Ventigrate.Shared.ExternalMembership.WebControls
{
    /// <summary>
    /// Code behind for RolesDisp.aspx
    /// </summary>
    public class RolesDisp : LayoutsPageBase
    {
        protected Label lblMessage;
        protected SPGridView RoleGrid;
        protected ToolBar onetidNavNodesTB;

        protected override bool RequireSiteAdministrator
        {
            get { return true; }
        }

        private ExtranetContext _ctx = null;
        internal ExtranetContext Ctx
        {
            get
            {
                if (null == _ctx)
                    _ctx = ExtranetContext.Default;

                return _ctx;
            }
        }

        protected override void OnLoad(EventArgs e)
        {
            // init
            this.CheckRights();

            // display error if membership provider not configured
            if (Ctx.MembershipProvider == null)
            {
                lblMessage.Text = "A Membership Provider has not been configured correctly. Check the web.config setttings for this web application.";
                RoleGrid.Visible = false;
                onetidNavNodesTB.Visible = false;
            }

            base.OnLoad(e);
        }
    }
}
